
// 题目描述：输入一个链表，输出该链表中倒数第k个结点// Description: Given a linked list, output the k-th node to tail
struct ListNode { 
    int val; struct ListNode *next; 
    ListNode(int x) : val(x), next(NULL) { }
};
class Solution {
    public: ListNode* FindKthToTail(ListNode* pListHead, unsigned int k) {
        if(pListHead==nullptr) return nullptr;
        ListNode* slow=pListHead;
        ListNode* fast=pListHead;
        for(int i=0;i<k;++i){
            if(fast==nullptr){
                return nullptr;
            }else{
                fast=fast->next;
            }
        }
        while(fast){
            slow=slow->next;
            fast=fast->next;
        }
        return slow;
    }
 };